﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using cocos2d;
using System.Threading;

// 貌似windows版本的窗体大小是800x480！

namespace RunCircle
{
    public class ResDef
    {
        //texture
        public static string g_GameResPListFile = @"plist/GameRes";
        public static string g_GameResTextureFile = @"plist/images/GameRes";
        //
        public static string g_GameResGUIPListFile = @"plist/GUI";
        public static string g_GameResGUITextureFile = @"plist/images/GUI";
        //
        public static string g_BlankTextureFile = @"images/blank";
        //
        public static CCSpriteBatchNode g_GUIBatchNode = new CCSpriteBatchNode();
        public static CCSpriteBatchNode g_GameBatchNode = new CCSpriteBatchNode();

        //music
        public static string g_JumpSound = @"music/JumpSound";
        public static string g_EleSound = @"music/EleSound";
        public static string g_FallSound = @"music/FallSound";
        public static string g_SpeedUpSound = @"music/SpeedUpSound";
        public static string g_PutTrap = @"music/PutTrap";
        public static string g_Hurray = @"music/Hurray";
        public static string g_CounterSound = @"music/Counter";
        public static string g_SelectSound = @"music/SelectSound";

        public static string g_OpeningMusic = @"music/OpeningMusic";
        public static string g_BackgroundMusic = @"music/BackMusic";
        //
        public static bool FinishedLoadRes = false;


        public static void  initRes(out int progress)
        {
            if (FinishedLoadRes == false)
            {
                CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(ResDef.g_GameResGUIPListFile);
                progress = 20;
                Thread.Sleep(100);
                CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(ResDef.g_GameResPListFile);

                progress = 30;
                Thread.Sleep(100);
                progress = 40;
                Thread.Sleep(100);
                progress = 50;
                Thread.Sleep(100);
                progress = 60;
                Thread.Sleep(100);
                progress = 70;
                Thread.Sleep(100);

                g_GameBatchNode = CCSpriteBatchNode.batchNodeWithFile(g_GameResTextureFile);

                progress = 80;
                Thread.Sleep(100);
                //
                g_GUIBatchNode = CCSpriteBatchNode.batchNodeWithFile(g_GameResGUITextureFile);
                progress = 90;
                Thread.Sleep(100);
            }
            //
            progress = 100;
            FinishedLoadRes = true;

        }
        public static void RemoveAllBatchNodeChildren()
        {
            g_GUIBatchNode.removeAllChildrenWithCleanup(true);
            g_GameBatchNode.removeAllChildrenWithCleanup(true);
        }


    }
    
}